<?php
namespace app\index\controller;
use think\Db;
use think\Request;
use app\index\service\QrcodeService;
class MakeCode
{
//    public function __construct(QrcodeService $qr_code)
//    {
//        $this->qr_code = $qr_code;
//    }

    public function last(Request $request){
        $content =  $request->get();
        // 自定义二维码配置
        $config = [
            'title'         => true,
            'title_content' =>false,
            'logo'          => false,
            'logo_url'      => './logo.png',
            'logo_size'     => 80,
        ];

//         直接输出
        $qr_url = '你好啊';

        $qr_code = new QrcodeService($config);
        $qr_img = $qr_code->createServer($qr_url);
        echo $qr_img;

        // 写入文件
        $qr_url = '这是个测试二维码';
        $file_name = 'static\qrcode';  // 定义保存目录

        $config['file_name'] = $file_name;
        $config['generate']  = 'writefile';

        $qr_code = new QrcodeService($config);
        $rs = $qr_code->createServer($qr_url);
//        print_r($rs);
//    echo("<img src={$rs['data']['url']}>");
        exit;
    }

}